package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.anno.MyAutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import io.swagger.v3.oas.annotations.Operation;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SetmealMapper {
    Page<SetmealVO> page(SetmealPageQueryDTO setmealPageQueryDTO);

    @Update("update setmeal set status = #{status} where id = #{id}")
    void changeStatus(Integer status, Long id);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @MyAutoFill(OperationType.INSERT)
    @Insert("insert into setmeal (id, category_id, name, price, status, description, image, create_time, update_time, create_user, update_user) values " +
            "(default,#{categoryId},#{name},#{price},#{status},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void add(Setmeal setmeal);

    void addSetmealDish(List<SetmealDish> setmealDishes);

    SetmealVO findById(Long id);

    Integer countStatusBySetmealIds(List<Long> ids);

    void deleteSetmealDishBySetmealIds(List<Long> ids);

    void deleteByIds(List<Long> ids);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @MyAutoFill(OperationType.UPDATE)
    void update(Setmeal setmeal);
}
